package com.example.dao;

import com.example.domain.Device;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/9/27<br/>
 *
 * @author QiuYang
 */
public class DeviceDao {
    private ConcurrentHashMap<String, Device> hub = new ConcurrentHashMap<>();

    public DeviceDao(){
        hub.put("1.1.1.1", new Device("1.1.1.1"));
        hub.put("2.2.2.2", new Device("2.2.2.2"));
    }

    public Device getDevice(String ip) {
        return hub.get(ip);
    }

    public Device updateDevice(Device device) {
        hub.put(device.getIp(), device);
        return hub.get(device.getIp());
    }
}
